﻿using DDD.Core;
using DDD.Domain.Abstract;
using DDD.Domain.Abstract.DomainManager;
using Microsoft.Extensions.DependencyInjection;
using Volo.Abp.Modularity;

namespace DDD.Domain;

[DependsOn(typeof(DomainAbstractModule), typeof(CoreModule))]
public sealed class DomainModule : AbpModule
{
    public override void ConfigureServices(ServiceConfigurationContext context)
    {
        context.Services.Scan(scan =>
        {
            scan.FromAssemblyDependencies(System.Reflection.Assembly.GetExecutingAssembly())
            .AddClasses(c => c.Where(t => t.IsAssignableTo(typeof(IDomainManager)) && !t.IsAbstract && !t.IsInterface))
            .AsSelf()
            .WithScopedLifetime();
        });
    }
}
